﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;

namespace VSTweaker.UI.ViewModels
{
    public class SettingsPageViewModel
    {
        public SettingsPageViewModel(VisualStudioVersion version)
        {
            if (version == null)
            {
                return;
            }

            var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);

            using (var vsKey = hklm.OpenSubKey(string.Format("Software\\Wow6432Node\\Microsoft\\VisualStudio\\{0}{1}", version.Version, version.Instance)))
            {
                if (vsKey == null) return;
                var toolsOptionsPagesKey = vsKey.OpenSubKey("ToolsOptionsPages");

                if (toolsOptionsPagesKey == null) return;
                Root = new SettingsPage(toolsOptionsPagesKey);
            }
        }

        public SettingsPage Root
        {
            get; private set;
        }
    }
}
